package cn.wolfcode.shop.cloud.mapper;

import domain.SeckillGood;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.util.List;

@Mapper
public interface SeckillGoodMapper {
    @Select("select*from t_seckill_goods")
    List<SeckillGood> querySeckillGoods();

    @Select("select*from t_seckill_goods where id=#{seckillId}")
    SeckillGood queryById(Long seckillId);

    @Update("update t_seckill_goods set stock_count=stock_count-1 where id=#{seckillId} and stock_count>0")
    int decr(Long seckillId);
    //回补真实库存
    @Update("update t_seckill_goods set stock_count=stock_count +1 where id=#{seckillId}")
    void incrCount(Long seckillId);

}
